<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js"></script>
    <title>p5-6</title>
</head>
<body>
    <div id="app">
            <input type="button" value="浪起来" @click="lang">
            <input type="button" value="低调" @click="end">
            <p>{{msg}}</p>
            <input type="button" value="查看定时器id" @click="look">
    </div>
    <script>
    var vm=new Vue({
        el:"#app",
        data:{
            msg:"稳住发育,别浪",
            intervalId:null
        },
        methods:{
            lang:function(){
                var that=this;
                if(that.intervalId==null){
                    that.intervalId=setInterval(function(){
                    var b=that.msg.substring(0,1);
                    var e=that.msg.substring(1);
                    that.msg=e+b;
                    },400)
                }
            },
            end:function(){
                clearInterval(this.intervalId);
                this.intervalId=null;
            },
            look(){
                console.log(this.intervalId);
            }
        }
    })
    </script>
</body>
</html>